package com.newly.driver.sdk.device.video.config;

import com.newly.driver.sdk.device.video.constants.DeviceConstant;
import com.newly.driver.sdk.device.video.service.api.IChannel;
import com.newly.driver.sdk.device.video.service.api.IDevice;
import com.newly.driver.sdk.device.video.service.api.IRecord;
import com.newly.driver.sdk.device.video.service.api.IStream;
import com.newly.driver.sdk.device.video.service.api.tencent.ITencentDevice;
import com.newly.driver.sdk.device.video.service.api.tencent.ITencentRecord;
import com.newly.driver.sdk.device.video.service.impl.qiniu.QiNiuChannel;
import com.newly.driver.sdk.device.video.service.impl.qiniu.QiNiuDevice;
import com.newly.driver.sdk.device.video.service.impl.qiniu.QiNiuStream;
import com.newly.driver.sdk.device.video.service.impl.tencent.TencentChannel;
import com.newly.driver.sdk.device.video.service.impl.tencent.TencentDevice;
import com.newly.driver.sdk.device.video.service.impl.tencent.TencentRecord;
import com.newly.driver.sdk.device.video.service.impl.tencent.TencentStream;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author gjm guan
 * @date 2021/10/19 16:19
 * @desc
 */
@Configuration
class DeviceConfig {

    @Value("${newly.cloud.device.platform}")
    private String platform;

    @Bean
    public IDevice device() {
        if (DeviceConstant.Platform.TENCENT.getValue().equals(platform)) {
            return new TencentDevice();
        } else if (DeviceConstant.Platform.QINIU.getValue().equals(platform)) {
            return new QiNiuDevice();
        }
        return null;
    }

    @Bean
    public IChannel channel() {
        if (DeviceConstant.Platform.TENCENT.getValue().equals(platform)) {
            return new TencentChannel();
        } else if (DeviceConstant.Platform.QINIU.getValue().equals(platform)) {
            return new QiNiuChannel();
        }
        return null;
    }

    @Bean
    public IStream stream() {
        if (DeviceConstant.Platform.TENCENT.getValue().equals(platform)) {
            return new TencentStream();
        } else if (DeviceConstant.Platform.QINIU.getValue().equals(platform)) {
            return new QiNiuStream();
        }
        return null;
    }

    @Bean
    public IRecord record() {
        if (DeviceConstant.Platform.TENCENT.getValue().equals(platform)) {
            return new TencentRecord();
        } else if (DeviceConstant.Platform.QINIU.getValue().equals(platform)) {
            return null;
        }
        return null;
    }

    @Bean
    public ITencentDevice tencentDevice() {
        return new TencentDevice();
    }

    @Bean
    public ITencentRecord tencentRecord() {
        return new TencentRecord();
    }
}
